//时间格式化
function sdf() {
    var date=new Date(val);
    var year=date.getFullYear();
    var month=date.getMonth()+1;
    month=month>9?month:('0'+month);
    var day=date.getDate();
    day=day>9?day:('0'+day);
    var hh=date.getHours();
    hh=hh>9?hh:('0'+hh);
    var mm=date.getMinutes();
    mm=mm>9?mm:('0'+mm);
    var ss=date.getSeconds();
    ss=ss>9?ss:('0'+ss);
    var time=year+'-'+month+'-'+day+' '+hh+':'+mm+':'+ss;
    return time;
}

//封装json
function getFormJson(frm) {  //frm：form表单的id
    var o = {};
    var a = $("#"+frm).serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [ o[this.name] ];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
}

//验证是否包含中文
function validateText(node) {
    var str =node.val().trim();
    if(/[\u4E00-\u9FA5]/.test(str)){
        return false;
    }else{
        return true;
    }
}

function getGridIds(node,rows){
    var ids = [];
    for(var i=0; i<rows.length; i++){
        ids.push(rows[i].id);
    }
    return ids;
}

function clearCheckGrid(node) {
    node.datagrid("clearChecked");
    node.datagrid("clearSelections");
}
//项目根目录
function getRootPath() {
    //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录，如： /uimcardprj/share/meun.jsp
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    //获取主机地址，如： http://localhost:8083
    var localhostPath = curWwwPath.substring(0, pos);
    //获取带"/"的项目名，如：/uimcardprj
    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
    return localhostPath ;

}
